﻿using StackExchange.Redis;
using Suk.Models.Config;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;

namespace Suk.Common
{
    public  class RedisHelper
    {
         
            /*
             * StackExchange.Redis
             */
            static IDatabase redis;
            static object lobject = new object();
            public RedisHelper()
            {
                if (redis == null)
                {
                    lock (lobject)
                    {
                        if (redis == null)
                    {
                        ConnectionConfigModel con = ConfigurationManager.GetAppSettings<ConnectionConfigModel>();
                        //  var connection = ConfigurationManager.GetAppSettings<ConnectionStringSettings>("ConnectionStrings");
                        ConnectionMultiplexer connectionMultiplexer = ConnectionMultiplexer.Connect(con.ConnectionConfig.ConnectionRedis.Connection);
                            redis = connectionMultiplexer.GetDatabase();
                        }
                    }
                }

            }

            public IDatabase Redis { get { return redis; } }
         

    }
}
